package sunwin.yoms.service.resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import sunwin.yoms.comm.YomsException;
import sunwin.yoms.dao.StadiumStateDao;
import sunwin.yoms.domain.resource.StadiumStateDomain;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by watson on 2015/7/30.
 */
@Service
public class StadiumStateService {
    @Autowired
    private StadiumStateDao stadiumStateDao;

    //查询
    public List<StadiumStateDomain> getStadiumState(StadiumStateDomain stadiumStateDomain) {
        List<StadiumStateDomain> stadiumStateDomains = new ArrayList<StadiumStateDomain>();
        stadiumStateDomains = stadiumStateDao.getDomainCollection(stadiumStateDomain);
        return stadiumStateDomains;
    }

    //id查询
    public StadiumStateDomain getStadiumStateById(int stadiumStateId) {
        return stadiumStateDao.getDomainById(stadiumStateId);
    }

    //总数量
    public int getStadiumStateCount() {
        return stadiumStateDao.getDomainCount();
    }

    //增加
    public void addSatdiumState(StadiumStateDomain stadiumStateDomain) throws YomsException {
        if (stadiumStateDao.addDomain(stadiumStateDomain) != 1) {
            throw new YomsException("增加公园场馆状态是失败");
        }
    }

    //删除
    public void deleteSatdiumState(StadiumStateDomain stadiumStateDomain) throws YomsException {
        if (stadiumStateDao.deleteDomain(stadiumStateDomain) != 1) {
            throw new YomsException("删除公园场馆状态是失败");
        }
    }

    //更新
    public void upSatdiumSatate(StadiumStateDomain stadiumStateDomain) throws YomsException {
        if (stadiumStateDao.updateDomain(stadiumStateDomain) != 1) {
            throw new YomsException("更新公园场馆状态是失败");
        }
    }
}

